home *** CD-ROM | disk | FTP | other *** search
- unit Cwunit1;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, ExtCtrls, Buttons, CWTools, CWCal, TabNotBk,
- Mask, Spin;
-
- type
- TForm1 = class(TForm)
- TabbedNotebook1: TTabbedNotebook;
- CWCalendar1: TCWCalendar;
- CWDateLabel1: TCWDateLabel;
- BitBtn1: TBitBtn;
- BitBtn2: TBitBtn;
- BitBtn3: TBitBtn;
- BitBtn4: TBitBtn;
- BitBtn5: TBitBtn;
- BitBtn6: TBitBtn;
- Bevel1: TBevel;
- CheckBox1: TCheckBox;
- CheckBox2: TCheckBox;
- CheckBox3: TCheckBox;
- ComboBox1: TComboBox;
- Label1: TLabel;
- ComboBox2: TComboBox;
- Label2: TLabel;
- ColorDialog1: TColorDialog;
- FontDialog1: TFontDialog;
- Bevel2: TBevel;
- BitBtn7: TBitBtn;
- BitBtn8: TBitBtn;
- Label3: TLabel;
- Bevel3: TBevel;
- Label4: TLabel;
- ComboBox3: TComboBox;
- Label6: TLabel;
- SpinEdit1: TSpinEdit;
- GroupBox1: TGroupBox;
- RadioButton1: TRadioButton;
- RadioButton2: TRadioButton;
- RadioButton3: TRadioButton;
- BitBtn9: TBitBtn;
- Label7: TLabel;
- Memo1: TMemo;
- BitBtn10: TBitBtn;
- CWCalendar2: TCWCalendar;
- Bevel4: TBevel;
- Bevel5: TBevel;
- Bevel6: TBevel;
- CWDateLabel2: TCWDateLabel;
- CWNavBtn1: TCWNavBtn;
- CWNavBtn2: TCWNavBtn;
- CWNavBtn3: TCWNavBtn;
- CWNavBtn4: TCWNavBtn;
- CWNavBtn5: TCWNavBtn;
- CWDateLabel3: TCWDateLabel;
- CWMonthCombo1: TCWMonthCombo;
- CWYearCombo1: TCWYearCombo;
- BitBtn11: TBitBtn;
- CWDateEdit1: TCWDateEdit;
- Label8: TLabel;
- Label9: TLabel;
- Label10: TLabel;
- Label11: TLabel;
- CWDateSpin1: TCWDateSpin;
- CWDateSpin2: TCWDateSpin;
- CWDateSpin3: TCWDateSpin;
- CWArrowBtn1: TCWArrowBtn;
- CWArrowBtn2: TCWArrowBtn;
- CWArrowBtn3: TCWArrowBtn;
- CWArrowBtn4: TCWArrowBtn;
- CWArrowBtn5: TCWArrowBtn;
- CWArrowBtn6: TCWArrowBtn;
- Label12: TLabel;
- Label13: TLabel;
- Label14: TLabel;
- CWDropDownEdit1: TCWDropDownEdit;
- CWCalendar3: TCWCalendar;
- ListBox1: TListBox;
- ListBox2: TListBox;
- CWNavBtn6: TCWNavBtn;
- CWNavBtn7: TCWNavBtn;
- Edit1: TEdit;
- CheckBox4: TCheckBox;
- BitBtn12: TBitBtn;
- CWDateLabel4: TCWDateLabel;
- Bevel7: TBevel;
- Label15: TLabel;
- Label16: TLabel;
- BitBtn13: TBitBtn;
- CWCalendar4: TCWCalendar;
- Label17: TLabel;
- Label18: TLabel;
- Label19: TLabel;
- Label20: TLabel;
- Label21: TLabel;
- Label22: TLabel;
- Label23: TLabel;
- Shape1: TShape;
- Bevel8: TBevel;
- CWDateLabel5: TCWDateLabel;
- CWArrowBtn7: TCWArrowBtn;
- CWArrowBtn8: TCWArrowBtn;
- CWArrowBtn9: TCWArrowBtn;
- CWArrowBtn10: TCWArrowBtn;
- Label24: TLabel;
- Label25: TLabel;
- Label26: TLabel;
- Label27: TLabel;
- Bevel9: TBevel;
- Bevel10: TBevel;
- Memo2: TMemo;
- Bevel11: TBevel;
- BitBtn14: TBitBtn;
- CWQuickCalendar1: TCWQuickCalendar;
- Button1: TButton;
- Label28: TLabel;
- Label29: TLabel;
- Label30: TLabel;
- Label31: TLabel;
- Label32: TLabel;
- Label33: TLabel;
- Label34: TLabel;
- Label35: TLabel;
- Label36: TLabel;
- Label37: TLabel;
- Label38: TLabel;
- Label39: TLabel;
- Label40: TLabel;
- Label41: TLabel;
- Label42: TLabel;
- Label43: TLabel;
- Label44: TLabel;
- Label45: TLabel;
- Label46: TLabel;
- Label47: TLabel;
- Label48: TLabel;
- Label49: TLabel;
- Label50: TLabel;
- Memo3: TMemo;
- Label51: TLabel;
- Label52: TLabel;
- Memo4: TMemo;
- BitBtn15: TBitBtn;
- Button2: TButton;
- Memo5: TMemo;
- Memo6: TMemo;
- Memo7: TMemo;
- Bevel12: TBevel;
- procedure CheckBox1Click(Sender: TObject);
- procedure CheckBox2Click(Sender: TObject);
- procedure CheckBox3Click(Sender: TObject);
- procedure ComboBox1Change(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure ComboBox2Change(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure CWCalendar1DateChange(Sender: TObject);
- procedure BitBtn4Click(Sender: TObject);
- procedure BitBtn5Click(Sender: TObject);
- procedure BitBtn3Click(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- procedure BitBtn6Click(Sender: TObject);
- procedure BitBtn7Click(Sender: TObject);
- procedure BitBtn8Click(Sender: TObject);
- procedure ComboBox3Change(Sender: TObject);
- procedure SpinEdit1Change(Sender: TObject);
- procedure RadioButton3Click(Sender: TObject);
- procedure RadioButton1Click(Sender: TObject);
- procedure RadioButton2Click(Sender: TObject);
- procedure BitBtn10Click(Sender: TObject);
- procedure CWCalendar2DateChange(Sender: TObject);
- procedure CWCalendar3Update(Sender: TObject);
- procedure CWCalendar3DragOver(Sender, Source: TObject; X, Y: Integer;
- State: TDragState; var Accept: Boolean);
- procedure CWCalendar3DragDrop(Sender, Source: TObject; X, Y: Integer);
- procedure Edit1DragOver(Sender, Source: TObject; X, Y: Integer;
- State: TDragState; var Accept: Boolean);
- procedure Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
- procedure CheckBox4Click(Sender: TObject);
- procedure CWCalendar3MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure CWCalendar3DateChange(Sender: TObject);
- procedure CWCalendar4DateChange(Sender: TObject);
- procedure CWCalendar4RangeChange(Sender: TObject);
- procedure CWCalendar4MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure CWNavBtn8Click(Sender: TObject);
- procedure CWArrowBtn10Click(Sender: TObject);
- procedure CWArrowBtn9Click(Sender: TObject);
- procedure CWCalendar4KeyUp(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure Button1Click(Sender: TObject);
- procedure CWDropDownEdit1Change(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
- SelectedDay : integer;
- LastEditDate : TDateTime;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.CheckBox1Click(Sender: TObject);
- begin
- CWCalendar1.Ctl3D := not CWCalendar1.Ctl3D;
- end;
-
- procedure TForm1.CheckBox2Click(Sender: TObject);
- begin
- CWCalendar1.GridLines := not CWCalendar1.GridLines;
- end;
-
- procedure TForm1.CheckBox3Click(Sender: TObject);
- begin
- CWCalendar1.ShowDayTitles := not CWCalendar1.ShowDayTitles;
- end;
-
- procedure TForm1.ComboBox1Change(Sender: TObject);
- begin
- case ComboBox1.ItemIndex of
- 0: CWCalendar1.DatePosition := Centered;
- 1: CWCalendar1.DatePosition := UpperLeft;
- 2: CWCalendar1.DatePosition := UpperRight;
- 3: CWCalendar1.DatePosition := LowerLeft;
- 4: CWCalendar1.DatePosition := LowerRight;
- end;
- end;
-
- procedure TForm1.FormShow(Sender: TObject);
- begin
- ComboBox1.ItemIndex := 0;
- ComboBox2.ItemIndex := 0;
- ComboBox3.ItemIndex := 0;
- Label26.Caption := DateToStr(Date);
- Label27.Caption := DateToStr(Date);
- CWDropDownEdit1.Text := DateToStr(Date);
- end;
-
- procedure TForm1.ComboBox2Change(Sender: TObject);
- begin
- case ComboBox2.ItemIndex of
- 0: CWCalendar1.DayTitleFormat := OneLetter;
- 1: CWCalendar1.DayTitleFormat := TwoLetters;
- 2: CWCalendar1.DayTitleFormat := ThreeLetters;
- 3: begin
- MessageDlg('Header font may have to be changed!', mtWarning, [mbOK],0);
- CWCalendar1.DayTitleFormat := FullName;
- end;
- end;
- end;
-
- procedure TForm1.BitBtn1Click(Sender: TObject);
- begin
- if ColorDialog1.Execute then
- begin
- CWCalendar1.BlockColor := ColorDialog1.Color;
- CWCalendar1.CellColor := ColorDialog1.Color;
- end;
- end;
-
- procedure TForm1.CWCalendar1DateChange(Sender: TObject);
- begin
- CWDateLabel1.SetDate;
- end;
-
- procedure TForm1.BitBtn4Click(Sender: TObject);
- begin
- FontDialog1.Font.Assign(CWCalendar1.HeaderFont);
- if FontDialog1.Execute then
- CWCalendar1.HeaderFont.Assign(FontDialog1.Font);
- end;
-
- procedure TForm1.BitBtn5Click(Sender: TObject);
- begin
- FontDialog1.Font.Assign(CWCalendar1.DateFont);
- if FontDialog1.Execute then
- CWCalendar1.DateFont.Assign(FontDialog1.Font);
- end;
-
- procedure TForm1.BitBtn3Click(Sender: TObject);
- begin
- ColorDialog1.Color := CWCalendar1.GridColor;
- if ColorDialog1.Execute then
- CWCalendar1.GridColor := ColorDialog1.Color;
- end;
-
- procedure TForm1.BitBtn2Click(Sender: TObject);
- begin
- ColorDialog1.Color := CWCalendar1.HeaderColor;
- if ColorDialog1.Execute then
- CWCalendar1.HeaderColor := ColorDialog1.Color;
- end;
-
- procedure TForm1.BitBtn6Click(Sender: TObject);
- begin
- ColorDialog1.Color := CWCalendar1.HiLightColor;
- if ColorDialog1.Execute then
- CWCalendar1.HiLightColor := ColorDialog1.Color;
- end;
-
- procedure TForm1.BitBtn7Click(Sender: TObject);
- begin
- ColorDialog1.Color := CWCalendar1.SundayColor;
- if ColorDialog1.Execute then
- CWCalendar1.SundayColor := ColorDialog1.Color;
- end;
-
- procedure TForm1.BitBtn8Click(Sender: TObject);
- begin
- ColorDialog1.Color := CWCalendar1.TodayColor;
- if ColorDialog1.Execute then
- CWCalendar1.TodayColor := ColorDialog1.Color;
- end;
-
- procedure TForm1.ComboBox3Change(Sender: TObject);
- begin
- case ComboBox3.ItemIndex of
- 0: CWCalendar1.StartOfWeek := Sunday;
- 1: CWCalendar1.StartOfWeek := Monday;
- 2: CWCalendar1.StartOfWeek := Tuesday;
- 3: CWCalendar1.StartOfWeek := Wednesday;
- 4: CWCalendar1.StartOfWeek := Thursday;
- 5: CWCalendar1.StartOfWeek := Friday;
- 6: CWCalendar1.StartOfWeek := Saturday;
- end;
- end;
-
- procedure TForm1.SpinEdit1Change(Sender: TObject);
- begin
- if SpinEdit1.Text = '' then exit;
- if SpinEdit1.Value < 1 then SpinEdit1.Value := 1;
- if SpinEdit1.Value > 100 then SpinEdit1.Value := 100;
- CWCalendar1.HeaderHeight := SpinEdit1.Value;
- end;
-
- procedure TForm1.RadioButton3Click(Sender: TObject);
- begin
- CWCalendar1.HiLight3D := hlNone;
- end;
-
- procedure TForm1.RadioButton1Click(Sender: TObject);
- begin
- CWCalendar1.HiLight3D := hlRaised;
- end;
-
- procedure TForm1.RadioButton2Click(Sender: TObject);
- begin
- CWCalendar1.HiLight3D := hlLowered;
- end;
-
- procedure TForm1.BitBtn10Click(Sender: TObject);
- begin
- if BitBtn10.Caption = 'Change Day Titles' then
- begin
- Memo1.Visible := true;
- BitBtn10.Caption := 'Apply Titles'
- end
- else
- begin
- if Memo1.Lines.Count < 6 then
- begin
- MessageDlg('Must have seven day titles!', mtError, [mbOK],0);
- Memo1.SetFocus;
- exit;
- end;
- Memo1.Visible := false;
- BitBtn10.Caption := 'Change Day Titles';
- CWCalendar1.DayTitles.Assign(Memo1.Lines);
- end;
- end;
-
- procedure TForm1.CWCalendar2DateChange(Sender: TObject);
- begin
- CWDateLabel2.SetDate;
- CWDateLabel3.SetDate;
- CWMonthCombo1.SetDate;
- CWYearCombo1.SetDate;
- CWDateEdit1.SetDate;
- end;
-
- procedure TForm1.CWCalendar3Update(Sender: TObject);
- begin
- CWCalendar3.AddText(Date,clRed,'Fire Someone!');
- CWCalendar3.AddText(Date + 2, clBlue, 'Phone George');
- CWCalendar3.AddText(Date + 2, clBlack, 'Get E-mail');
- CWCalendar3.AddText(Date + 8, clGreen, 'Buy Calendar-');
- CWCalendar3.AddText(Date + 8, clGreen, 'Works');
- CWCalendar3.AddText(Date - 3, clMaroon,'Meeting');
-
- CWCalendar3.AddBitmap(Date,'CWCheck');
- CWCalendar3.AddBitmap(Date + 2, 'CWPhone');
- CWCalendar3.AddBitmap(Date + 8, 'CWToDo');
- CWCalendar3.AddBitmap(Date - 3, 'CWAlarm');
- end;
-
- procedure TForm1.CWCalendar3DragOver(Sender, Source: TObject; X,
- Y: Integer; State: TDragState; var Accept: Boolean);
- begin
- if Source is TListBox then
- Accept := True;
- end;
-
- procedure TForm1.CWCalendar3DragDrop(Sender, Source: TObject; X,
- Y: Integer);
- var ABitMap: array[0..12] of char;
- AColor : TColor;
- begin
- SelectedDay := CWCalendar3.GetDayXY(X,Y);
- if (Source = ListBox1) or (Source = ListBox2) then
- begin
- if SelectedDay <> 0 then
- begin
- with CWCalendar3 do
- begin
- if Source = ListBox1 then
- begin
- case ListBox1.ItemIndex of
- 0: AColor := clGreen;
- 1: AColor := clBlue;
- 2: AColor := clRed;
- 3: AColor := clBlack;
- end;
- AddText(EncodeDate(Year,Month,SelectedDay),AColor,ListBox1.Items[ListBox1.ItemIndex])
- end
- else
- begin
- case ListBox2.ItemIndex of
- 0: StrPCopy(ABitMap,'CWALARM');
- 1: StrPCopy(ABitMap,'CWBULBON');
- 2: StrPCopy(ABitMap,'CWCHECK');
- 3: StrPCopy(ABitMap,'CWGLOBE');
- 4: StrPCopy(ABitMap,'CWLIBRARY');
- 5: StrPCopy(ABitMap,'CWMAILBOX');
- 6: StrPCopy(ABitMap,'CWNIGHT');
- 7: StrPCopy(ABitMap,'CWPENCIL');
- 8: StrPCopy(ABitMap,'CWPHONE');
- 9: StrPCopy(ABitMap,'CWTODO');
- end;
- AddBitmap(EncodeDate(Year,Month,SelectedDay),ABitMap);
- end;
- end;
- end;
- CWCalendar3.RefreshDay(SelectedDay);
- end;
- end;
-
- procedure TForm1.Edit1DragOver(Sender, Source: TObject; X, Y: Integer;
- State: TDragState; var Accept: Boolean);
- begin
- if Source = CWCalendar3 then
- Accept := true;
- end;
-
- procedure TForm1.Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
- begin
- if SelectedDay = 0 then exit;
- if Source = CWCalendar3 then
- begin
- with CWCalendar3 do
- Edit1.Text := FormatDateTime('mmmm d, yyyy', EncodeDate(Year,Month,SelectedDay));
- end;
- end;
-
- procedure TForm1.CheckBox4Click(Sender: TObject);
- begin
- if CheckBox4.Checked then CWCalendar3.DragDate := true
- else CWCalendar3.DragDate := false;
- end;
-
- procedure TForm1.CWCalendar3MouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- if CWCalendar3.DragDate then
- SelectedDay := CWCalendar3.GetDayXY(X,Y);
- end;
-
- procedure TForm1.CWCalendar3DateChange(Sender: TObject);
- begin
- CWDateLabel4.SetDate;
- end;
-
- procedure TForm1.CWCalendar4DateChange(Sender: TObject);
- begin
- CWDateLabel5.SetDate;
- Label26.Caption := DateToStr(CWCalendar4.RangeStartDate);
- Label27.Caption := DateToStr(CWCalendar4.RangeEndDate);
- end;
-
- procedure TForm1.CWCalendar4RangeChange(Sender: TObject);
- begin
- CWDateLabel5.SetDate;
- end;
-
- procedure TForm1.CWCalendar4MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- Label26.Caption := DateToStr(CWCalendar4.RangeStartDate);
- Label27.Caption := DateToStr(CWCalendar4.RangeEndDate);
- end;
-
- procedure TForm1.CWNavBtn8Click(Sender: TObject);
- begin
- CWCalendar4.ResetRange;
- end;
-
- procedure TForm1.CWArrowBtn10Click(Sender: TObject);
- begin
- CWCalendar4.ResetRange;
- end;
-
- procedure TForm1.CWArrowBtn9Click(Sender: TObject);
- begin
- CWCalendar4.ResetRange;
- end;
-
- procedure TForm1.CWCalendar4KeyUp(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- if Key in [VK_PRIOR, VK_NEXT, VK_LEFT,VK_UP, VK_RIGHT, VK_DOWN] then
- begin
- Label26.Caption := DateToStr(CWCalendar4.RangeStartDate);
- Label27.Caption := DateToStr(CWCalendar4.RangeEndDate);
- end;
- end;
-
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- CWQuickCalendar1.Execute;
- Button1.Caption := CWQuickCalendar1.DisplayDate;
- end;
-
- procedure TForm1.CWDropDownEdit1Change(Sender: TObject);
- var TheYear, TheMonth, TheDay : word;
- ADay : array [1..7] of string;
- begin
- ADay[1] := 'Sunday';
- ADay[2] := 'Monday';
- ADay[3] := 'Tuesday';
- ADay[4] := 'Wednesday';
- ADay[5] := 'Thursday';
- ADay[6] := 'Friday';
- ADay[7] := 'Saturday';
-
- if LastEditDate = 0 then LastEditDate := Date;
- DecodeDate(CWDropDownEdit1.EditDate,TheYear,TheMonth,TheDay);
- with CWCalendar1 do
- begin
- Label40.Caption := IntToStr(DayNumber(CWDropDownEdit1.EditDate));
- Label41.Caption := IntToStr(DaysRemaining(0,CWDropDownEdit1.EditDate));
- Label42.Caption := IntToStr(DaysRemaining(1,CWDropDownEdit1.EditDate));
- Label43.Caption := IntToStr(DaysInYear(TheYear));
- Label44.Caption := IntToStr(DaysInMonth(TheYear,TheMonth));
- Label45.Caption := IntToStr(DaysBetween(LastEditDate,CWDropDownEdit1.EditDate));
- Label46.Caption := ADay[FirstOfMonth(TheYear,TheMonth)];
- Label47.Caption := ADay[WeekDay(CWDropDownEdit1.EditDate)];
- Label48.Caption := IntToStr(WeekNumber(CWDropDownEdit1.EditDate));
- if IsLeapYear(TheYear) then
- Label49.Caption := 'Yes'
- else Label49.Caption := 'No';
- LastEditDate := CWDropDownEdit1.EditDate;
- end;
- end;
-
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- if Memo4.Visible = false then
- begin
- Memo4.Visible := true;
- Label51.Caption := 'Registering Your Copy of CalendarWorks';
- Button2.Caption := 'Registering with a Credit Card';
- end
- else
- begin
- Memo4.Visible := false;
- Label51.Caption := 'Credit Card Registration';
- Button2.Caption := 'Registering CalendarWorks';
- end;
- end;
-
- end.
-